﻿@using FikriKibar.Globalization
@using FikriKibar.UI.WebCommon.Helpers
@using FikriKibar.Entities.Composite.BaseModels
@using FikriKibar.Entities.Concrete
@model ListModel<RoleLanguageLine>


@{
    ViewBag.Title = Resources.RoleManagement;
    Layout = "~/Views/Shared/ContentLayout.cshtml";
}

<div class="container-fluid">
    <div class="row">
        <div class="col-lg-12">
            <h1 class="page-header">@Resources.RoleManagement</h1>
        </div>
    </div>
    <div class="row">
        <div class="col-lg-12">
            @using (Html.BeginForm("Index", "Role", FormMethod.Post, new { @class = "form-filter" }))
            {
                <div class="panel panel-default panel-filter">
                    <div class="panel-heading">
                        <i class="fa fa-search fa-fw"></i>
                        @Resources.FilterForm
                        <div class="pull-right">
                            <div class="btn-group">
                                <a href="#" class="panel-filter-toogle btn btn-default btn-xs">
                                    <i class="fa fa-angle-up  fa-fw" title="@Resources.Hide"></i>
                                    <i class="fa fa-angle-down fa-fw" title="@Resources.Show"></i>
                                </a>
                            </div>
                        </div>
                    </div>
                    <div class="panel-body panel-filter-body">
                        <div class="row">
                            <div class="col-lg-12" role="form">
                                <div class="row">
                                    <div class="col-lg-3">
                                        <div class="form-group">
                                            <label for="Searched">@Resources.SearchedKey</label>
                                            @Html.FikriKibarTextBoxFor(m => m.Searched, new {@class = "form-control", onblur = "FilterFormSubmit()" })
                                        </div>

                                    </div>
                                    <div class="col-lg-3">
                                        <div class="form-group">
                                            <label for="SelectedLanguageCode">@Resources.Language</label>
                                            @Html.FikriKibarDropDownListFor(m => m.SelectedLanguageCode, new SelectList(Model.LanguageList, "LanguageCode", "LanguageName", Model.SelectedLanguageCode), new {@class = "form-control", onchange = "FilterFormSubmit()" })
                                        </div>

                                    </div>

                                    <div class="col-lg-3">
                                        <div class="form-group">
                                            <label for="SelectedStatus">@Resources.Status</label>
                                            @Html.FikriKibarDropDownListFor(m => m.SelectedStatus, new SelectList(new List<object>
                                            {
                                                new { value = -1 , text ="["+ Resources.All+"]"  },
                                                new { value = 1 , text = Resources.Approved  },
                                                new { value = 0 , text = Resources.NotApproved   }
                                            }, "value", "text", Model.SelectedStatus), new { @class = "form-control", onchange = "FilterFormSubmit()" })
                                        </div>
                                    </div>


                                    <div class="col-lg-3">
                                        <div class="form-group">
                                            <label for="Paging_CurrentPageSize">@Resources.ShowingCount</label>

                                            @Html.FikriKibarDropDownListFor(m => m.Paging.CurrentPageSize, new SelectList(Model.Paging.PageSizeList, "Key", "Value", Model.Paging.PageSizeList.ToString()), new { @class = "form-control", onchange = "FilterFormSubmit()" })

                                            @Html.FikriKibarHiddenFor(m => m.Paging.CurrentPage)
                                            @Html.FikriKibarHiddenFor(m => m.Paging.TotalPageCount)
                                            @Html.FikriKibarHidden("sEmptyTable", null, Resources.NotFound)

                                        </div>

                                    </div>

                                    
                                </div>


                            </div>
                        </div>
                    </div>
                </div>

                if (Model.ItemList != null)
                {
                    <div class="panel panel-default panel-datatable">
                        <div class="panel-heading">
                            <i class="fa fa-fw fa-table"></i> @Resources.Records
                            <div class="pull-right">
                                <div class="btn-group">
                                    <a href="@Url.Action("Add","Role")" class="panel-datatable-new btn btn-warning btn-xs">
                                        <i class="fa fa-plus fa-fw"></i> @Resources.NewRecord
                                    </a>
                                </div>
                            </div>
                        </div>
                        <div class="panel-body panel-datatable-body">

@if (Model.Paging.TotalItemCount > 0)
{

    <div class="row">
        <div class="col-lg-12">
            <table id="datagrid" class="table dataTable table-striped table-bordered table-hover table-responsive">
                <thead>
                    <tr>
                        <th class="no-sort-first">@Html.FikriKibarCheckBox("chkgridAll", true)</th>
                        <th>#</th>
                        <th>@Resources.Name</th>
                        <th>@Resources.CreatedBy</th>
                        <th>@Resources.CreateDate</th>
                        <th class="no-sort">@Resources.Status</th>

                        <th class="no-sort">@Resources.Edit</th>

                        <th class="no-sort">@Resources.Delete</th>
                    </tr>
                </thead>
                <tbody>
                    @foreach (var item in Model.ItemList)
                    {
                        <tr>

                            <td class="text-center">

                                @Html.FikriKibarCheckBox("chkgrid-" + item.Role.Id, true, new { @class = "chkgrid" })


                            </td>
                            <td class="text-right datakeyfield">@item.Role.Id</td>
                            <td>@item.RoleName</td>
                            <td>@item.Role.User_CreatedBy.FullName</td>
                            <td class="text-center">@item.Role.CreateDate.ToString("dd/MM/yyyy HH:mm:ss")</td>
                            <td class="text-center">@Html.DisplayFor(e => item.IsApproved)</td>

                            <td class="text-center"><a href="@Url.Action("Update", "Role", new {id = item.Role.Id, language = item.Language.LanguageCode})" class="btn btn-primary btn-xs"><i class="fa fa-edit fa-fw"></i> @Resources.Update</a></td>



                            <td class="text-center"><a href="#" class="btn btn-danger btn-xs DeleteButton" data-confirm-href="@Url.Action("Delete", "Role", new {id = item.Role.Id, language = item.Language.LanguageCode})" data-confirm-title="@Resources.AreYouSure" data-confirm-message="@Resources.AreYouSureDelete" data-confirm-ok="@Resources.Yes" data-confirm-cancel="@Resources.No"><i class="fa fa-remove fa-fw"></i> @Resources.Delete</a></td>
                        </tr>
                    }

                </tbody>
            </table>


        </div>
    </div>


                            <div class="row">
                                <div class="col-lg-12">
                                    @Html.FikriKibarHiddenFor(e => e.IdsForSort)
                                    @Html.FikriKibarHiddenFor(e => e.IdsForDelete)
                                    @Html.FikriKibarHiddenFor(e => e.IdsForApprove)
                                    <a href="javascript:" id="ButtonSortSave" class="btn btn-primary"><i class="fa fa-sort-alpha-asc fa-fw"></i> @Resources.SortSave</a> <a href="#" id="ButtonApproveSave" class="btn btn-success" data-confirm-title="@Resources.AreYouSure" data-confirm-message="@Resources.AreYouSureApproveSelected" data-confirm-ok="@Resources.Yes" data-confirm-cancel="@Resources.No"><i class="fa fa-check fa-fw"></i> @Resources.ApproveSelected</a> <a href="#" id="ButtonDeleteSelected" class="btn btn-danger" data-confirm-title="@Resources.AreYouSure" data-confirm-message="@Resources.AreYouSureDeleteSelected" data-confirm-ok="@Resources.Yes" data-confirm-cancel="@Resources.No"><i class="fa fa-remove"></i> @Resources.DeleteSelected</a>
                                </div>
                            </div>

}


                           </div>

                        <div class="panel-footer text-center">


                           

                            @if (Model.Paging.TotalItemCount > 0)
                            {

                                <ul class="pagination pagination-sm">
                                    @for (var i = 1; i <= Model.Paging.TotalPageCount; i++)
                                    {
                                        <li class="item @(i == Model.Paging.CurrentPage ? "active" : "")">

                                            <a href="javascript:">@i</a>
                                        </li>

                                    }
                                </ul>

                                <div class="alert alert-info alert-dismissable">
                                    <button class="close" aria-hidden="true" data-dismiss="alert" type="button">×</button>
                                    @Resources.TotalCount: <strong>@Model.Paging.TotalItemCount</strong>

                                </div>
                            }
                            else
                            {
                                <div class="alert alert-danger alert-dismissable">
                                    <button class="close" aria-hidden="true" data-dismiss="alert" type="button">×</button>
                                   <strong>@Resources.NotFound</strong>

                                </div>
                            }


                           


                        </div>
                    </div>


                }


            }



        </div>
    </div>
</div>

